/**
 * AI Model Face & Hair Detail Fix Template
 *
 * This template performs detailed face and hair enhancement for AI model photos.
 * It uses segmentation masks and local inpainting to improve facial features and hair quality.
 *
 * Features:
 * - Automatic face and hair segmentation
 * - Two-stage local inpainting (hair first, then face)
 * - Configurable denoising strength
 * - High-quality detail enhancement
 */

import type { WorkflowTemplateData } from '../types';

export const aiModelFaceHairFixTemplate: WorkflowTemplateData = {
  metadata: {
    id: 'ai-model-face-hair-fix',
    name: 'AI Model Face & Hair Detail Fix',
    description: 'Professional face and hair detail enhancement for AI model photos using segmentation and local inpainting',
    category: 'enhancement',
    tags: ['face-enhancement', 'hair-enhancement', 'portrait', 'ai-model', 'detail-fix', 'inpainting'],
    version: '1.0.0',
    author: 'ComfyUI SDK'
  },
  parameters: {
    input_image: {
      type: 'string',
      description: 'Input image filename to enhance',
      required: true,
      default: '20250806-190606.jpg'
    },
    face_prompt: {
      type: 'string',
      description: 'Positive prompt for face enhancement',
      required: true,
      default: 'A girl, slim figure, oval face, beauty, Pink and greasy lips，'
    },
    face_denoise: {
      type: 'string',
      description: 'Denoising strength for face enhancement',
      required: true,
      default: '0.30'
    }
  },

  workflow: {
    "6": {
      "inputs": {
        "模糊强度": 3,
        "mask": [
          "53",
          1
        ]
      },
      "class_type": "EG_ZZ_MHHT",
      "_meta": {
        "title": "2🐕遮罩边缘滑条快速模糊"
      }
    },
    "8": {
      "inputs": {
        "ckpt_name": "juggernaut_reborn_sd1,5.safetensors"
      },
      "class_type": "CheckpointLoaderSimple",
      "_meta": {
        "title": "Checkpoint加载器（简易）"
      }
    },
    "9": {
      "inputs": {
        "text": "Smooth long hair,Hair details, quality hair,Smooth hair",
        "clip": [
          "8",
          1
        ]
      },
      "class_type": "CLIPTextEncode",
      "_meta": {
        "title": "CLIP文本编码"
      }
    },
    "10": {
      "inputs": {
        "text": "Frizzy hair, dry hair, split ends,bad quality, poor quality, doll, disfigured, jpg, toy, bad anatomy, missing limbs, missing fingers, 3d, cgi",
        "clip": [
          "8",
          1
        ]
      },
      "class_type": "CLIPTextEncode",
      "_meta": {
        "title": "CLIP文本编码"
      }
    },
    "13": {
      "inputs": {
        "text": [
          "59",
          0
        ],
        "clip": [
          "8",
          1
        ]
      },
      "class_type": "CLIPTextEncode",
      "_meta": {
        "title": "CLIP文本编码"
      }
    },
    "14": {
      "inputs": {
        "text": "(NSFW:1.2),(worst quality:1.2),(low quality:1.2),(normal quality:1.2),low resolution,watermark,",
        "clip": [
          "8",
          1
        ]
      },
      "class_type": "CLIPTextEncode",
      "_meta": {
        "title": "CLIP文本编码"
      }
    },
    "22": {
      "inputs": {
        "detail_method": "VITMatte(local)",
        "detail_erode": 44,
        "detail_dilate": 6,
        "black_point": 0.030000000000000006,
        "white_point": 0.99,
        "process_detail": true,
        "device": "cuda",
        "max_megapixels": 2,
        "image": [
          "30",
          0
        ],
        "segformer_pipeline": [
          "28",
          0
        ]
      },
      "class_type": "LayerMask: SegformerUltraV2",
      "_meta": {
        "title": "LayerMask: Segformer Ultra V2"
      }
    },
    "25": {
      "inputs": {
        "seed": 646617836820462,
        "steps": 30,
        "cfg": 4.5200000000000005,
        "sampler_name": "dpmpp_2s_ancestral",
        "scheduler": "karras",
        "denoise": 0.4,
        "重绘模式": "原图",
        "遮罩延展": 10,
        "仅局部重绘": true,
        "局部重绘大小": 768,
        "重绘区域扩展": 50,
        "遮罩羽化": 5,
        "TEXT": "2🐕出品，必出精品",
        "model": [
          "8",
          0
        ],
        "image": [
          "30",
          0
        ],
        "vae": [
          "8",
          2
        ],
        "mask": [
          "47",
          0
        ],
        "positive": [
          "9",
          0
        ],
        "negative": [
          "10",
          0
        ]
      },
      "class_type": "EG_CYQ_JB",
      "_meta": {
        "title": "2🐕局部重绘采样器"
      }
    },
    "26": {
      "inputs": {
        "seed": 969968724502727,
        "steps": 30,
        "cfg": 4.5200000000000005,
        "sampler_name": "dpmpp_2s_ancestral",
        "scheduler": "karras",
        "denoise": [
          "71",
          0
        ],
        "重绘模式": "原图",
        "遮罩延展": 10,
        "仅局部重绘": true,
        "局部重绘大小": 768,
        "重绘区域扩展": 50,
        "遮罩羽化": 5,
        "TEXT": "2🐕出品，必出精品",
        "model": [
          "8",
          0
        ],
        "image": [
          "25",
          1
        ],
        "vae": [
          "8",
          2
        ],
        "mask": [
          "6",
          0
        ],
        "positive": [
          "13",
          0
        ],
        "negative": [
          "14",
          0
        ]
      },
      "class_type": "EG_CYQ_JB",
      "_meta": {
        "title": "2🐕局部重绘采样器"
      }
    },
    "28": {
      "inputs": {
        "model": "segformer_b3_clothes",
        "face": false,
        "hair": true,
        "hat": false,
        "sunglass": false,
        "left_arm": false,
        "right_arm": false,
        "left_leg": false,
        "right_leg": false,
        "left_shoe": false,
        "right_shoe": false,
        "upper_clothes": false,
        "skirt": false,
        "pants": false,
        "dress": false,
        "belt": false,
        "bag": false,
        "scarf": false
      },
      "class_type": "LayerMask: SegformerClothesPipelineLoader",
      "_meta": {
        "title": "LayerMask: Segformer Clothes Pipeline"
      }
    },
    "30": {
      "inputs": {
        "image": "{{input_image}}"
      },
      "class_type": "LoadImage",
      "_meta": {
        "title": "加载图像"
      }
    },
    "44": {
      "inputs": {
        "masks": [
          "22",
          1
        ]
      },
      "class_type": "Mask Fill Holes",
      "_meta": {
        "title": "Mask Fill Holes"
      }
    },
    "47": {
      "inputs": {
        "expand": 5,
        "incremental_expandrate": 5,
        "tapered_corners": true,
        "flip_input": false,
        "blur_radius": 9.4,
        "lerp_alpha": 0.9900000000000002,
        "decay_factor": 1,
        "fill_holes": false,
        "mask": [
          "44",
          0
        ]
      },
      "class_type": "GrowMaskWithBlur",
      "_meta": {
        "title": "Grow Mask With Blur"
      }
    },
    "52": {
      "inputs": {
        "model": "segformer_b3_clothes",
        "face": true,
        "hair": false,
        "hat": false,
        "sunglass": true,
        "left_arm": false,
        "right_arm": false,
        "left_leg": false,
        "right_leg": false,
        "left_shoe": false,
        "right_shoe": false,
        "upper_clothes": false,
        "skirt": false,
        "pants": false,
        "dress": false,
        "belt": false,
        "bag": false,
        "scarf": false
      },
      "class_type": "LayerMask: SegformerClothesPipelineLoader",
      "_meta": {
        "title": "LayerMask: Segformer Clothes Pipeline"
      }
    },
    "53": {
      "inputs": {
        "detail_method": "VITMatte(local)",
        "detail_erode": 6,
        "detail_dilate": 4,
        "black_point": 0.01,
        "white_point": 0.99,
        "process_detail": false,
        "device": "cuda",
        "max_megapixels": 2,
        "image": [
          "30",
          0
        ],
        "segformer_pipeline": [
          "52",
          0
        ]
      },
      "class_type": "LayerMask: SegformerUltraV2",
      "_meta": {
        "title": "LayerMask: Segformer Ultra V2"
      }
    },
    "58": {
      "inputs": {
        "filename_prefix": "ComfyUI",
        "images": [
          "26",
          1
        ]
      },
      "class_type": "SaveImage",
      "_meta": {
        "title": "保存图像"
      }
    },
    "59": {
      "inputs": {
        "String": "A girl, slim figure, oval face, beauty, Pink and greasy lips，{{face_prompt}}"
      },
      "class_type": "String",
      "_meta": {
        "title": "String"
      }
    },
    "71": {
      "inputs": {
        "Number": "{{face_denoise}}"
      },
      "class_type": "Float",
      "_meta": {
        "title": "Float"
      }
    }
  }
};
